<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改zbj')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-zbj-edit" th:object="${zbj}">
            <input name="zbjId" th:field="*{zbjId}" type="hidden">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">标题：</label>
                    <div class="col-sm-8">
                        <input name="zbjTitle" th:field="*{zbjTitle}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">导语：</label>
                    <div class="col-sm-8">
                        <input name="zbjDy" th:field="*{zbjDy}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">开始时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="zbjStarttime" th:value="${#dates.format(zbj.zbjStarttime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">结束时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="zbjEndtime" th:value="${#dates.format(zbj.zbjEndtime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">直播状态：</label>
                    <div class="col-sm-8">
                        <select name="zbjStauts" class="form-control" th:with="type=${@dict.getType('sys_zbj_type')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{zbjStauts}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">主持人头像：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="zcrTx" th:field="*{zcrTx}">
                       <div class="file-loading">
                            <input class="form-control file-upload" id="zcrTx" name="file" type="file">
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">主持人昵称：</label>
                    <div class="col-sm-8">
                        <input name="zcrName" th:field="*{zcrName}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">直播间类型：</label>
                    <div class="col-sm-8">
                        <input name="typeId" th:field="*{typeId}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">标签：</label>
                    <div class="col-sm-8">
                        <input name="zbjLable" th:field="*{zbjLable}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">封面图：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="zbjCover" th:field="*{zbjCover}">
                       <div class="file-loading">
                            <input class="form-control file-upload" id="zbjCover" name="file" type="file">
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">聊天室：</label>
                    <div class="col-sm-8">
                        <input name="croomId" th:field="*{croomId}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">logo：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="zbjLogo" th:field="*{zbjLogo}">
                       <div class="file-loading">
                            <input class="form-control file-upload" id="zbjLogo" name="file" type="file">
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "system/zbj";
        $("#form-zbj-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-zbj-edit').serialize());
            }
        }

        $("input[name='zbjStarttime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='zbjEndtime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>
</body>
</html>